package com.example.administrator.caigou51.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.bean.AccountBean;
import com.example.administrator.caigou51.bean.PayBean;
import com.example.administrator.caigou51.bean.PayTypeBean;
import com.example.administrator.caigou51.global.App;
import com.example.administrator.caigou51.global.Constant;
import com.example.administrator.caigou51.recyclerCard.basic.MaterialListView;
import com.example.administrator.caigou51.recyclerCard.card.AddAgainGoodsCard;
import com.example.administrator.caigou51.request.BaseResponse;
import com.example.administrator.caigou51.request.ICallBackForRequestServer;
import com.example.administrator.caigou51.request.RequestServerManager;
import com.example.administrator.caigou51.widget.dialog.SweetDialogManager;

import java.util.List;

import cn.pedant.SweetAlert.SweetAlertDialog;

/**
 * Created by Administrator on 2016/9/20/020.
 */
public class ZhuanZhangPayActivity extends GBaseActivity {
    MaterialListView material_listview;
    private TextView textViewMoney;
    private TextView textViewZhangHao;
    private TextView textViewShouKuanRen;
    private TextView textViewKaiHuXing;
    private TextView textViewYongTuBeiZhu;
    private TextView textViewSumit;
    private PayBean payBean;
    private AccountBean accountBean;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        super.setContentViewFor720_1280(R.layout.activity_zhuanzhang);
        findViewByIds();
        initDatas();
        fillArrayInListView();
    }

    private void findViewByIds() {
        textViewMoney = (TextView) findViewById(R.id.textViewMoney);
        textViewZhangHao = (TextView) findViewById(R.id.textViewZhangHao);
        textViewShouKuanRen = (TextView) findViewById(R.id.textViewShouKuanRen);
        textViewKaiHuXing = (TextView) findViewById(R.id.textViewKaiHuXing);
        textViewYongTuBeiZhu = (TextView) findViewById(R.id.textViewYongTuBeiZhu);
        textViewSumit = (TextView) findViewById(R.id.textViewSumit);textViewSumit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TaskSumit(false);
            }
        });

    }
    private void initDatas() {
        setTopTitle("转账支付");
        payBean= (PayBean) getIntent().getSerializableExtra(PayMoneyActivity.TagPayBean);
        accountBean= (AccountBean) getIntent().getSerializableExtra(PayMoneyActivity.TagAccountBean);

        textViewMoney.setText("￥"+payBean.getPay_amount());
        textViewZhangHao.setText(accountBean.getAccount());
        textViewShouKuanRen.setText(accountBean.getReceiver());
        textViewKaiHuXing.setText(accountBean.getBank_name());
        textViewYongTuBeiZhu.setText(accountBean.getRemarks());
    }
    private void fillArrayInListView() {

    }

    private void TaskSumit(final boolean isloadmore) {
        RequestServerManager.getInstanceDIY().handleMethodDIY((GBaseActivity) getActivity(), null, isloadmore, null,
                Constant.getRootUrl() + Constant.Action.Action_PayZhuangZhang, Constant.Action.Action_PayZhuangZhang, RequestServerManager.getInstanceDIY().
                        getRequestParams(Constant.Action.Action_PayZhuangZhang, App.getUserBean().getUserid(),App.getUserBean().getSession_id(),payBean.getOrder_id(),payBean.getPayment_id()), BaseResponse.class, new ICallBackForRequestServer<BaseResponse>() {
                    @Override
                    public void onSuccess(BaseResponse result) {
                        // JSONObject jsonObject = (JSONObject) result.getData();
                     //   List<PayTypeBean> payTypeBeanList = JSON.parseArray(result.getData().toString(), PayTypeBean.class);
                    //    SweetDialogManager.getInstance().showDialogByTitleText(ZhuanZhangPayActivity.this,"下单成功！","",false,false);
                   /*     SweetDialogManager.getInstance().showDialogBySuccessTitleText(ZhuanZhangPayActivity.this, "下单成功！", "", false, false, new SweetAlertDialog.OnSweetClickListener() {
                            @Override
                            public void onClick(SweetAlertDialog sweetAlertDialog) {
                                Intent intent = new Intent(ZhuanZhangPayActivity.this, TradeSuccessActivity.class);
                                startActivity(intent);
                            }
                        });*/
                        Intent intent = new Intent(ZhuanZhangPayActivity.this, TradeSuccessActivity.class);
                        intent.putExtra(TradeSuccessActivity.TagPayStyle,"转账支付");
                        intent.putExtra(TradeSuccessActivity.TagPayTotal,payBean.getPay_amount()+"");
                        intent.putExtra(TradeSuccessActivity.TagPayTips,"订单提交成功！");
                        startActivity(intent);
                    }

                    @Override
                    public void onFail(int type, String errorMsg, String json) {

                    }
                });
    }


}